<?php
class ActivitySevenEventVo extends SzAbstractMySqlVo
{

    private $userId;
    private $indexId;
    private $startTime;
    private $signedDay;

    /**
     * Initialize ActivitySevenEventVo.
     *
     * @param $userId
     * @param $indexId
     * @param $startTime
     * @param $signedDay
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return ActivitySevenEventVo
     */
    public function __construct($userId, $indexId, $startTime, $signedDay, $isInsert = false) {
        $this->userId = $userId;
        $this->indexId = $indexId;
        $this->startTime = $startTime;
        $this->signedDay = json_decode($signedDay, true);

        $this->isInsert = $isInsert;
        $this->voClassName = 'ActivitySevenEventVo';
        $this->ormName = 'ActivitySevenEvent';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'indexId' => $this->getIndexId(),
            'startTime' => $this->getStartTime(),
            'signedDay' => ($needEncode) ? $this->getSignedDay() : $this->getRawSignedDay(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'indexId' => $this->getIndexId(),
            'startTime' => $this->getStartTime(),
            'signedDay' => ($needEncode) ? $this->getSignedDay() : $this->getRawSignedDay(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getIndexId(),
            $this->getStartTime(),
            $this->getSignedDay(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getIndexId()
    {
        return $this->indexId;
    }

    public function setIndexId($val)
    {
        $this->saveColumnStatus(1, $this->indexId);
        $this->indexId = $val;
    }

    public function getStartTime()
    {
        return $this->startTime;
    }

    public function setStartTime($val)
    {
        $this->saveColumnStatus(2, $this->startTime);
        $this->startTime = $val;
    }

    public function getSignedDay()
    {
        return json_encode($this->signedDay);
    }

    public function getRawSignedDay()
    {
        return $this->signedDay;
    }

    public function setSignedDay($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 128) {
            SzLogger::get()->error('[ActivitySevenEventVo] The length of column signedDay exceed the limit, length / limit: ' . $encodedLength . ' / 128');
            throw new SzException(10522, array('ActivitySevenEventVo', '128', $encodedLength));
        } else if ($encodedLength > 115) {
            SzLogger::get()->warn('[ActivitySevenEventVo] The length of column signedDay exceed the warning level, length / limit: ' . $encodedLength . ' / 128');
        }
        $this->saveColumnStatus(3, $this->signedDay);
        $this->signedDay = $val;
    }

}